package cn.z2huo.demo.redis.spring.service.impl;

import cn.z2huo.demo.redis.spring.service.api.StringRedisTemplateService;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Service;

/**
 * <p>
 *
 * @author z2huo
 */
@Service
public class StringRedisTemplateServiceImpl implements StringRedisTemplateService {

    @Autowired
    private StringRedisTemplate redisTemplate;

    @Override
    public void set(String key, String value) {
        if (StringUtils.isBlank(key)) {
            throw new RuntimeException("key is null");
        }
        redisTemplate.opsForValue().set(key, value);
    }

    @Override
    public String get(String key) {
        return redisTemplate.opsForValue().get(key);
    }

}
